package com.gy.edu.news;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.gy.edu.R;
import com.gy.edu.base.BaseFragment;
import com.gy.edu.news.adapter.NewsHomeAdapter;
import com.gy.edu.util.AnimUtil;

/**
 * 作者：gy on 16/12/21
 * 说明：资讯首页
 */
public class NewsHomeFragment extends BaseFragment {

    private ListView listView;
    private NewsHomeAdapter adapter;

    @Override
    protected View setView(LayoutInflater inflater) {
        View view = inflater.inflate(R.layout.fragment_news_home,null);
        _baseBack.setVisibility(View.INVISIBLE);
        setTitleMsg("资讯");
        return view;
    }

    @Override
    protected void initView() {
        listView = (ListView) _rootView.findViewById(R.id.news_home_listview);
        adapter = new NewsHomeAdapter(mContext);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void setListener() {
        super.setListener();
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(mContext,NewDetailActivity.class);
                intent.putExtra("position",position);
                startActivity(intent);
                AnimUtil.pushLeftInAndOut(getActivity());
            }
        });
    }

    @Override
    protected void fillData() {
        super.fillData();
        listView.setAdapter(adapter);
    }
}
